package com.sigmatrix.h5.web.rebate;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.sigmatrix.h5.entity.DisTerminalShop;
import com.sigmatrix.h5.service.DisTerminalShopService;
import com.sigmatrix.h5.service.common.ServiceHelper;
import com.sigmatrix.h5.web.BaseController;
import com.sigmatrix.h5.web.Result;
import com.sigmatrix.h5.web.args.RegistTerminalShopParam;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 
 *@ClassName: DisTerminalShopController
 *@Description: 终端门店相关接口
 *@author MH
 *@date 2017年12月20日 上午10:36:47
 */
@Api(tags="终端门店接口")
@RestController
@RequestMapping("/rebate/shop")
public class DisTerminalShopController extends BaseController{
	
	@Autowired
	private DisTerminalShopService disTerminalShopService;
	
//	@Autowired
//	private ShortMessageService shortMessageService;
	
	@ApiOperation("直接注册终端门店，免审核")
	@PostMapping("api/save")
	public Result<DisTerminalShop> addShop(@RequestBody RegistTerminalShopParam vo){
		DisTerminalShop shop = disTerminalShopService.directSave(vo);
		return ok(shop);
	}
	@ApiOperation("注册终端门店，需要审核，并且需要生成crm账号")
	@PostMapping("api/regist")
	public Result<DisTerminalShop> registShop(@RequestBody RegistTerminalShopParam vo,@RequestParam String code){
		ServiceHelper.selectSmsService(null).validateCode(code);
		DisTerminalShop shop = disTerminalShopService.registShop(vo);
		return ok(shop);
	}
	
}
